package com.android.youwenchuang.ui.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.android.youwenchuang.databinding.FragmentMineBinding;
import com.android.youwenchuang.ui.activity.CarActivity;
import com.android.youwenchuang.ui.activity.OrderActivity;
import com.android.youwenchuang.ui.activity.SettingsActivity;
import com.android.youwenchuang.util.UserData;
import com.blankj.utilcode.util.ActivityUtils;
import com.blankj.utilcode.util.AppUtils;

public class MineFragment extends Fragment {

    private FragmentMineBinding viewBinding;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        viewBinding = FragmentMineBinding.inflate(LayoutInflater.from(requireContext()));
        return viewBinding.getRoot();
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        viewBinding.tvContent.setText(UserData.user.name);
        //设置界面
        viewBinding.llSettings.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ActivityUtils.startActivity(SettingsActivity.class);
            }
        });
        //退出登录
        viewBinding.llExit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                AppUtils.relaunchApp();
            }
        });
        //购物车
        viewBinding.llCar.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ActivityUtils.startActivity(CarActivity.class);
            }
        });
        //我的订单
        viewBinding.llOrder.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ActivityUtils.startActivity(OrderActivity.class);
            }
        });

    }
}
